﻿using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;

using System;

namespace load
{
  public class Class1
  {
    private bool ev = false;
    [CommandMethod("ww")]
    public void ww()
    {
      var doc = Application.DocumentManager.MdiActiveDocument;
      var db = doc.Database;
      var ed = doc.Editor;
      var ad = new AssemblyDependent("E:\\cad-c\\\\bin\\Debug\\demo.dll");  //写上你dll的路径
      var msg= ad.Load();

      bool allyes = true;
      foreach (var item in msg)
      {
        if (!item.LoadYes)
        {
          ed.WriteMessage(Environment.NewLine + "**" + item.Path +
                          Environment.NewLine + "**此文件已加载过,重复名称,重复版本号,本次不加载!" +
                          Environment.NewLine);
          allyes = false;
        }
      }
      if (allyes)
      {
        ed.WriteMessage(Environment.NewLine + "**链式加载成功!" + Environment.NewLine);
      }
      if (!ev) { AppDomain.CurrentDomain.AssemblyResolve += RunTimeCurrentDomain.DefaultAssemblyResolve; ev = true; }
     
    }

  }
}
